package com.dongdongshop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.pojo.item.TbItem;
import com.dongdongshop.service.search.SearchService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.List;

@Controller
@RequestMapping("search")
public class SearchController {

    @Reference
    private SearchService searchService;

    @RequestMapping("searchInfo")
    public String searchInfo(String name, Model model) throws IOException {
        List<TbItem> itemList = searchService.findItemByElasticSearch(name);
        model.addAttribute("itemList",itemList);
        return "search";
    }
}
